﻿using Abp.AspNetCore.Mvc.Controllers;
using Batman.Cms.Core.Utils;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Runtime.Loader;
using System.Web;

namespace Batman.Jianbei.Forum.Controllers.Users
{
    public class AdminLoginController : AbpController
    {
        /// <summary>
        /// 生成管理后台登录用的二维码
        /// </summary>
        /// <returns></returns>
        public IActionResult QrCode()
        {
            var callback = "http://192.168.31.150:8080/#/login/confirm";
            callback = HttpUtility.UrlEncode(callback);

            var qrcode = QrCodeUtil.GenerateUrlQrCode("http://192.168.31.150:8080/api/weixinAuth/silent?url=" + callback);

            return File(qrcode, "image/png");
        }

        /// <summary>
        /// 获取登录用的二维码
        /// </summary>
        /// <returns></returns>
        public IActionResult GetLoginQrCode()
        {
            var url = $"/AdminLogin/QrCode";

            return Json(new { qrcode = url });
        }
    }
}
